var removeDuplicates = function(nums) {
    const n = nums.length
    let j=1
    for(let i=0;i<n;i++){
        if(nums[i]==nums[j-1]) continue
        nums[j++]=nums[i]
    }
    //console.log(nums);
    return j
};
console.log(removeDuplicates([1,1,2]));